const router = require('koa-router')()
const Koa = require('koa')
const app = new Koa()
// 配置koa-body处理文件上传
/*router.use((req, res, next) => {
  const authHeader = req.headers.authorization;
  if (authHeader) {
    const token = authHeader.split(' ')[1];
    jwt.verify(token, 'secret', (err, payload) => {
      if (err) {
        return res.status(401).json({ message: 'token 不正确' });
      }
      req.user = payload;
      next();
    });
  } else {
    res.status(401).json({ message: '未提供 token' });
  }
});*/
module.exports = router
router.post('/upload', async (ctx, next) => {
    console.log(111);
    console.log(ctx.request.header);
    console.log(ctx.request.files); // 打印上传的文件信息
    // 其它处理文件上传的逻辑
    ctx.body = "success";
  });
router.get('/upload', function (ctx, next) {
    ctx.body = 'this is a upload!'
  });
module.exports = router